<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>门店商品库存管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">

		var subFlag = true;
		var goodsCode = null;
		var storeCode = null;
		$(document).ready(function() {
			$("#importBox_goods").hide();
		});
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function shows(gc,sc){
			goodsCode = gc;
			storeCode = sc;
			$("#importBox_goods").show();
		}
		
		function confirm_imbox(){
			if($("#forms").valid()){
				if(subFlag){
					subFlag = false;
					$("#code").val(goodsCode);
					$("#storeCode").val(storeCode);
					$("#queryPartsCode2").val($("#queryPartsCode").val());
					$("#queryMaterielCode2").val($("#queryMaterielCode").val());
					$("#queryCnName2").val($("#queryCnName").val());
					$("#querySource2").val($("#querySource").val());
					$("#queryStoreCode2").val($("#queryStoreCode").val());
					$("#forms").submit();
				}else{
					loading('正在提交，请稍等...');
				}
			}
		}
		
		function close_imbox(){
			$("#importBox_goods").hide();
		}
		
		
	</script>
	
	<style>
		#importBox_goods{
			position:fixed;
			padding:0 15px;
			width:240px;
			background:#FFF;
			top:10%;
			left:25%;
			margin:0 auto;
			border:1px solid #CCC;
			box-shadow:3px 3px 10px 4px #DDD;
			z-index: 9999;
			
		}
		#importBox_goods .ib_title{
			margin-bottom:35px;
		}
		
		#importBox_goods .ib_bottom{
			margin-bottom:35px;
		}
       
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/goodsstorestock/">门店商品库存管理列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="goods" action="${ctx}/sys/goodsstorestock/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>配件编号：</label>
				<form:input path="queryPartsCode" htmlEscape="false" maxlength="100" class="input-medium"/>
			</li>
			<li><label>物料编号：</label>
				<form:input path="queryMaterielCode" htmlEscape="false" maxlength="100" class="input-medium"/>
			</li>
			<li><label>商品名称：</label>
				<form:input path="queryCnName" htmlEscape="false" maxlength="100" class="input-medium"/>
			</li>
			<li class="clearfix"></li>
		</ul>
		<ul class="ul-form">
			<li><label>商品来源：</label>
				<form:select path="querySource" class="input-medium">
					<option value="">所有</option>
					<form:options items="${goodsourceList}" itemValue="value" itemLabel="label"/>
				</form:select>
			</li>
			<li><label>所属门店：</label>
				<form:select path="queryStoreCode" class="input-medium">
					<option value="">所有</option>
					<form:options items="${storeList}" itemValue="code" itemLabel="cnName"/>
				</form:select>
			</li>
			<li class="btns">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
			</li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>序号</th>
				<th>物料编号</th>
				<th>配件编号</th>
				<th>商品编号</th>
				<th>商品来源</th>
				<th>商品名称</th>
				<th>制造商品牌</th>
				<th>售价</th>
				<th>会员价</th>
				<th>库存</th>
				<th>所属门店</th>
				<shiro:hasPermission name="sys:goodsstorestock:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="goods" varStatus="status" >
			<tr>
				<td>
					${status.index+1}
				</td>
				<td>
					${goods.materielCode}
				</td>
				<td>
					${goods.partsCode}
				</td>
				<td>
					${goods.code}
				</td>
				<td>
					<c:forEach items="${goodsourceList}" var="bean">
						<c:if test="${bean.value == goods.source}">
							${bean.label}
						</c:if>
					</c:forEach>
				</td>
				<td>
					<a href="${ctx}/sys/goodsplatformmanger/goodsDetail?goodsCode=${goods.code}&tagUrl=${ctx}/sys/goodsstorestock/list&tagName=门店商品库存管理列表">${goods.cnName}</a>
				</td>
				<td>
					${goods.venderName}
				</td>
				<td>
					${goods.price}
				</td>
				<td>
					${goods.memberPrice}
				</td>
				<td>
					${goods.storeGoodsStock}
				</td>
				<td>
					${goods.storeCnName}
				</td>
				<shiro:hasPermission name="sys:goodsstorestock:edit">
				<td>
					<a href="#" onclick="shows('${goods.code}','${goods.storeCode}')">录入</a>
					<a href="${ctx}/sys/goodsstorestock/form?id=${goods.id}" >历史记录</a>
				</td>
				</shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	
	<!-- 弹框 -->
	<div id="importBox_goods" class="hide">
			<div class='ib_title'>
			 <h3>请输入录入库存数</h3>
			</div>
			 <form action="${ctx}/sys/goodsstorestock/save" method="post" id="forms">
					 <input type="text" id="storeGoodsStock" name="storeGoodsStock" class="required notFolat" maxlength="9"/>
                     <input id="code" name="code" type="hidden" />
                     <input id="storeCode" name="storeCode" type="hidden" />
                     <input id="queryPartsCode2" name="queryPartsCode" type="hidden"/>
                     <input id="queryMaterielCode2" name="queryMaterielCode" type="hidden"/>
                     <input id="queryCnName2" name="queryCnName" type="hidden"/>
                     <input id="querySource2" name="querySource" type="hidden"/>
                     <input id="queryStoreCode2" name="queryStoreCode" type="hidden"/>
			        </form>
			<div class='ib_bottom'>
			 		<input id="btnCancel" class="btn" type="button" style='' value="确定" onclick="confirm_imbox()"/>
					<input id="btnCancel" class="btn" type="button" style='margin-left:10px;' value="取消" onclick="close_imbox()"/>
			</div>	
	</div>
</body>
</html>